"""
针对不同的接口 生成对应的测试数据
提供测试数据
"""

def home_page_data():
    """
    主题首页接口的测试用例
    :return:
    """
    tab_v = ["ask", "share", "job", "good"]
    limit_v = [1, 50, 51]
    # 将数据排列组合一下
    test_tab_limit_data = []
    for tab in tab_v:
        for limit in limit_v:

            expect_tab = tab  # 期望的tab值
            # 需要注意: 当limit = 51, 期望的结果是50
            if limit >= 51:  # limit为51 时候
                expect_limit = 50  # 设置为50
            else:  # 其他场景
                expect_limit = limit  # 期望的limit 值
            test_tab_limit_data.append((tab, limit, expect_tab, expect_limit))  # (tab,limit) 元组数据类型
            # print(f'当tab的值为{tab}的时候， limit值为 {limit}, 期望结果中的tab值{expect_tab},期望结果中的limit')
    # print("生成测试数据为", test_tab_limit_data)
    return test_tab_limit_data



def create_topic_data():
    tokens = ["","xxxxxxyyyy","e18de36f-d9ce-47e6-a2aa-1cf6508ec10","e18de36f-d9ce-47e6-a2aa-1cf6508ec10b"]
    titles = ["","helloworld"]
    tabs = ["ask","share","job","dev",""]
    contents = ["","helloworld"]
    testdata = []
    # 组合数据
    for token in tokens:
        for title in titles:
            for tab in tabs:
                for content in contents:
                    # 设置对应的断言
                    expect_success = False
                    if not token == "e18de36f-d9ce-47e6-a2aa-1cf6508ec10b":
                        expect_err_msg = "错误的accessToken"
                    elif title == "":
                        expect_err_msg ="标题不能为空"
                    elif tab == "":
                        expect_err_msg = "必须选择一个版块"
                    elif content == "":
                        expect_err_msg = "内容不可为空"
                    else:
                        #只有当发帖成功的时候 success 的结果才会 True
                        expect_success = True
                        # 发帖成功的时候，返回结果的数据类型跟失败的类型不一样，只对success 进行断言即可
                        expect_err_msg = ""

                    testdata.append((token,title,tab,content,expect_success,expect_err_msg))

    return testdata


if __name__ == '__main__':
    data = create_topic_data()
    print(data)

